<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>User Manage - ADMIN - BIG Data Center</title>

    <link rel="stylesheet" type="text/css"
          href="${host}/static/DataTables-1.10.12/media/css/dataTables.bootstrap.min.css">

    <style type="text/css" class="init">
    </style>

    <script type="text/javascript" src="${host}/static/DataTables-1.10.12/media/js/jquery.dataTables.js"></script>
    <script type="text/javascript"
            src="${host}/static/DataTables-1.10.12/media/js/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript" class="init">
        $(document).ready(function () {
            $('#dataTable').DataTable({
                pageLength: 100
            });
        });


        function ajaxfunction(id, status, obj) {
            //alert(id);
            //alert($(this));
            //alert($(obj).text());

            $.ajax({
                url: "${host}/admin/ajaxaudit",
                type: "POST",
                dataType: "json",
                async: false,
                data: {'id': id, 'status': status},
                cache: false,
                success: function (data) {

                    //alert(data);
                    if (data == 2) {
                        $(obj).text("已审核");
                    }
                    if (data == 1) {
                        $(obj).text("未审核");
                    }


                },
                error: function () {
                    // Handle upload error
                    // ...
                    alert("获取数据出错");
                }
            });

        }
    </script>
</head>

<body>
<div class="index">
    <h3 class="text-primary">已注册用户列表</h3>
    <form action="${host}/admin/q" method="get" class="form-inline">
        <table class="table table-condensed">
            <tr>
                <th class="col-md-1">用户类别</th>
                <td class="col-md-4">
                    <select class="form-control" name="userType">
                        <option value="">-- 请选择 --</option>
                        <option value="PI/Senior Scientist">PI/Senior Scientist</option>
                        <option value="Postdoc/Junior Scientist">Postdoc/Junior Scientist</option>
                        <option value="Student">Student</option>
                        <option value="Other">Other</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>审核状态</th>
                <td><select class="form-control" name="status">
                    <option value="">-- 请选择 --</option>
                    <option value="0">未激活</option>
                    <option value="1">未审核</option>
                    <option value="2">审核通过</option>
                </select></td>
            </tr>
            <tr>
                <th>是否邀请报告人</th>
                <td><select class="form-control" name="isInvited">
                    <option value="">-- 请选择 --</option>
                    <option value="0">是</option>
                    <option value="1">否</option>
                </select></td>
            </tr>
            <tr>
                <th>12号晚餐</th>
                <td><select class="form-control" name="twelveDinner">
                    <option value="">-- 请选择 --</option>
                    <option value="0">是</option>
                    <option value="1">否</option>
                </select></td>
            </tr>
            <tr>
                <th>13号午餐</th>
                <td><select class="form-control" name="thirteenLunch">
                    <option value="">-- 请选择 --</option>
                    <option value="0">是</option>
                    <option value="1">否</option>
                </select></td>
            </tr>
            <tr>
                <th>13号晚餐</th>
                <td><select class="form-control" name="thirteenDinner">
                    <option value="">-- 请选择 --</option>
                    <option value="0">是</option>
                    <option value="1">否</option>
                </select></td>
            </tr>
            <tr>
                <td><button type="submit" class="btn btn-block btn-primary">过滤查询</button></td>
                <td></td>
            </tr>
        </table>
    </form>
    <label class="label label-success">Total: ${total}</label>
    <label class="label label-danger">参加会议的人数：<a href="${host}/admin/home?show=0"> ${attendNumber}</a></label>
    <label class="label label-warning">参加13号午餐人数：<a href="${host}/admin/home?show=1"> ${thirteenLunch}</a></label>
    <label class="label" style="background-color: #2d9c12">参加12号晚餐人数：<a href="${host}/admin/home?show=2"> ${twelveDinner}</a></label>
    <label class="label label-info">参加13号晚餐人数：<a href="${host}/admin/home?show=3"> ${thirteenDinner}</a></label>
    <br>
    <br>
    <!-- <h3 class="text-success"><i class="fa fa-newspaper-o"></i> News List</h3> -->

    <div class="table-responsive"><table id="dataTable" class="table table-bordered table-striped">
        <thead>
        <tr class="active">
			<th>No.</th>
            <th>Username&Email</th>
            <th>Department</th>
            <th>Telephone</th>
            <th>IsInvited</th>
            <th>UserType</th>
            <th>Status</th>
            <th>Operation</th>
        </tr>
        </thead>
        <tbody class="mytbody">
        <c:forEach items="${users}" var="user" varStatus="status">
            <tr>


                <th>${ status.count}</th>
                <th>${user.username}<br/>${user.email}</th>
                <th>${user.department}</th>
                <th>${user.telephone}</th>
                <c:if test="${user.isInvited==0}">
                    <td>Yes</td>
                </c:if>
                <c:if test="${user.isInvited!=0}">
                    <td>NO</td>
                </c:if>
                <td>${user.userType}</td>
                <c:if test="${user.status==0||user.status==null}">
                    <td>未激活</td>
                </c:if>
                <c:if test="${user.status==1}">
                    <%--			<td><a
                                    href="${host}/admin/audit?id=${user.id}&status=${user.status}" >未审核</a></td>--%>
                    <td><a onclick="ajaxfunction(${user.id},${user.status},this);return false;"
                           href="#">未审核</a></td>
                </c:if>
                <c:if test="${user.status==2}">
                    <%--<td><a
                        href="${host}/admin/audit?id=${user.id}&status=${user.status}">已审核</a></td>--%>

                    <td><a
                            onclick="ajaxfunction(${user.id},${user.status},this);return false;" href="#">已审核</a></td>
                </c:if>
                <td>
                        <%--  <c:if  test="${user.status==1}">  <a href="${host}/ybp/audit?id=${user.id}" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i> Audit</a></c:if> --%>
                    <a href="${host}/ybp/edit?id=${user.id}" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a>
                            <a href="${host}/admin/drop?id=${user.id}" class="btn btn-danger btn-xs" onclick="return confirm('Delete it ?')"><i class="fa fa-trash-o"></i></a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table></div>


</div>

</body>
</html>
